class Solution {
public:
    vector<string> ret;
    vector<string> letterCasePermutation(string s) {
        dfs(s, 0);
        return ret;
    }
    void dfs(string s, int begin)
    {
        while (begin < s.size() && (s[begin] > 'z' || (s[begin] < 'a' && s[begin]>'Z') || s[begin] < 'A')) begin++;
        if (begin >= s.size())
        {
            ret.push_back(s);
            return;
        }
        dfs(s, begin + 1);
        if (s[begin] >= 'a' && s[begin] <= 'z')
        {
            s[begin] -= 32;
        }
        else
        {
            s[begin] += 32;
        }

        dfs(s, begin + 1);
    }
};